-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Lensflare.js to be able to dispose textures #13355
Conversation
Update Lensflare.js so to be able to properly dispose the textures otherwise we have memory issues... In order to properly dispose the textures added into the Lensflare ( new THREE.Lensflare() ) by the ( new THREE.LensflareElement() ) we must place them into the object. So then we can do for example: for( var i = scene.children.length - 1; i >= 0; i-- ) { for( var j = 0, n = scene.children[i].elements.length; j <n; j++ ){ scene.children[i].elements[m].texture.dispose(); } }
I would keep |
By setting So in the BUT Actually its not only about disposing textures. What if you want to change on the fly for example the size of the LensflareElement ? By having |
Yeah, that's clear. I refer to something different. If the user creates textures, then it's also his responsibility to dispose them. Why? Because, the user can apply these textures also to other materials.
|
I think this is modification to this.dispose = function () {
material1a.dispose();
material1b.dispose();
material2.dispose();
tempMap.dispose();
occlusionMap.dispose();
for ( var i = 0; i < elements.length; i ++ ) {
elements[ i ].texture.dispose();
}
}; And I agree 👍 |
@mrdoob better use : |
Indeed! Would you like to amend the PR? |
I am sorry but I don't understand what you mean by that... |
Would you like to change this PR with the proposed implementation? |
yes |
@@ -127,7 +127,7 @@ THREE.Lensflare = function () { | |||
|
|||
// | |||
|
|||
var elements = []; | |||
elements = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to keep the var
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes i did not notice that...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll clean it up after merging.
Thanks! |
Update Lensflare.js so to be able to properly dispose the textures otherwise we have memory issues...
In order to properly dispose the textures added into the Lensflare ( new THREE.Lensflare() ) by the ( new THREE.LensflareElement() ) we must place them into the object. So then we can do for example:
Note: we could probably use the "children" array to store the THREE.LensflareElement instead of "elements".
Note: the Lensflare dispose method does not dispose textures.